package controllerLayer;
import DBLayer.DbSalesOrder;
import modelLayer.*;

public class SalesOrderCtr 
{
	DbSalesOrder dbSale = new DbSalesOrder();	

//find an order by salesId
public SalesOrder searchBySalesId(int _salesId)
{
	return dbSale.findSalesId(_salesId, true);
}

//find an order by customer phoneNo
public SalesOrder searchByCustomerPhoneNo(String _customerPhoneNo)
{
	return dbSale.findCustomerPhoneNo(_customerPhoneNo, false);
}

public boolean addNewOrder(int _salesId, String _salesDate, double _totalAmount, String _deliveryStatus, String _deliveryDate, double _discount, double _deliveryCosts, String _customerPhoneNo, String _invoiceNo)
{
	boolean succes = false;
	
	SalesOrder tempOrder = new SalesOrder(_salesId, _salesDate, _totalAmount, _deliveryStatus, _deliveryDate, _discount, _deliveryCosts, _customerPhoneNo, _invoiceNo);
	dbSale.insertSalesOrder(tempOrder);
	
	if(searchBySalesId(_salesId) != null)
	{
		succes = true;
	}
	return succes;
}

/*public ArrayList<SalesOrder> listAllSalesOrders()
{
	ArrayList<SalesOrder> listAllSalesOrders;
	listAllSalesOrders = dbSale.listAllSalesOrders();
	return listAllSalesOrders;
}*/

}
